﻿using System.Windows;
using Red.Core;

namespace Red.Controls.Curve.ViewModels
{
    public enum EInteroplationType
    {
        CPT_Constant,
        CPT_Linear,
        CPT_BezierQuadratic,
        CPT_BezierCubic,
        CPT_Fake
    }

    public class ControlPoint : ViewModel
    {
        private Point _coords;
        private EInteroplationType _type;

        public double Time
        {
            get { return _coords.X; }
            set
            {
                if ( value != _coords.X )
                {
                    OnPropertyChanging();
                    _coords.X = value;
                    OnPropertyChanged();
                }
            }
        }

        public double Value
        {
            get { return _coords.Y; }
            set
            {
                if ( value != _coords.Y )
                {
                    OnPropertyChanging();
                    _coords.Y = value;
                    OnPropertyChanged();
                }
            }
        }

        public Point Coordinates
        {
            get { return _coords; }
            set
            {
                if ( value != _coords )
                {
                    OnPropertyChanging();
                    _coords = value;
                    OnPropertyChanged();
                }
            }
        }

        public EInteroplationType Type
        {
            get { return _type; }
            set
            {
                if ( value != _type )
                {
                    OnPropertyChanging();
                    _type = value;
                    OnPropertyChanged();
                }
            }
        }

        public ControlPoint( EInteroplationType type = EInteroplationType.CPT_Linear )
        {
            Type = type;
        }

        public ControlPoint( double time, double value, EInteroplationType type = EInteroplationType.CPT_Linear )
        {
            Type = type;
            _coords = new Point( time, value );
        }
    }
}
